<?php

function _tranxuantuan_dap_an() {
	$html = '';
	$module_path = drupal_get_path('module', 'tranxuantuan');
	$dir    = $module_path .'/da';
	$files1 = glob($dir .'/*.json',GLOB_BRACE);
	//dpm($files1);
		$html .= <<< AAA
		<table id='dap_an'> 
			 
					 <tr>
						<td style="color: red;">Mã đề</td>
AAA;
for ($i =1; $i<41; $i++) {
	$html .= <<< AAA
						<td style="color: #28FFF0;">{$i}</td>
AAA;
}
	foreach($files1 as $file1) {
		$file = file_get_contents($file1);
		$file2 = unserialize($file);
		$made = substr($file1, 34, 3);
		//dpm($file2);
						$html .= <<< AAA
					</tr>
					<tr>
					<td style="color: red;">{$made}</td>
AAA;
		for($i =1; $i<= count($file2); $i++) {
		$j=$i-1;
				$html .= <<< AAA

						<td>{$file2[$j]['dap_an']}</td>
AAA;
		}

	}
	
$html.= <<< AAA
						</tr>
				</table>
AAA;
return $html;
}


function list_files($directory = '.')
{
    if ($directory != '.')
    {
        $directory = rtrim($directory, '/') . '/';
    }
    
    if ($handle = opendir($directory))
    {
        while (false !== ($file = readdir($handle)))
        {
            if ($file != '.' && $file != '..')
            {
                echo $file.'<br>';
            }
        }
        
        closedir($handle);
    }
}



